// SceneObject.h-  This is the base object of all objects in 
// the scene graph.
//////////////////////////////////////////////////////////////////////

#if !defined SCENEOBJECT_H
#define SCENEOBJECT_H

#include<vector>  // Use the STL Vector as our container
#include "Vec3.h"

enum RTTI_OBJECT_TYPE
{
	RTTI_MODEL,   
	RTTI_LIGHT,    
	RTTI_DUMMY,
	RTTI_PRIMITIVE,
	RTTI_TRANSFORM,
	RTTI_MATERIAL,
	RTTI_CAMERA,
	RTTI_PROJECTILE
};

class SceneObject  
{

protected:
	SceneObject*					parentObject;
	std::vector<SceneObject*>		childrenObjects;
	Vec3 pos;
	
public:
	SceneObject();
	virtual ~SceneObject();
	// assessors/mutators
	void setParent(SceneObject* parent)	 { parentObject = parent; }
	void addChild(SceneObject* child);
	void dropChild(SceneObject* child);
	std::vector<SceneObject*>* getChildrenObjects() { return &childrenObjects; } 
	virtual RTTI_OBJECT_TYPE getType() const = 0;
    
	// Force every child to have a render and update methods
	virtual void render(float timeElapsed) = 0;
	virtual void update(float timeElapsed) = 0;
	virtual void collide(SceneObject* caller, float timeElapsed){
            if(this->getType()== RTTI_MODEL ||this->getType()== RTTI_PRIMITIVE){
            std::cout << "checking collide " << std::endl;    
            std::cout<< "type" << this->getType()<< std::endl; 
            std::cout << "diff pos " <<caller->getPos()-this->getPos()<< std::endl; 
            std::cout<< "my pos" << this->getPos()<< std::endl; 
            std::cout<< "your pos" << caller->getPos()<< std::endl; }            
            if((((caller->getPos()-this->getPos())[2])<0.5f)
                   &&(((caller->getPos()-this->getPos())[2])>-0.5f)
                   &&(caller!=this)){
                   std::cout<< "!!!!!!!!!!!!!!!BOOM!!!!!!!!!!!!" <<std::endl;
            }
    }
            

    // Optional method to override
    virtual void postRender(float timeElapsed) {}    
    
    //camera
    virtual void setCamera(float timeElapsed){}
    virtual void unsetCamera(float timeElapsed){}
    
    //position
    Vec3 getPos(){return pos;}
};

#endif // SCENEOBJECT_H
